<?php
class RaidKills extends Zend_Db_Table_Abstract {
	protected $_rowClass = 'RaidKillRow';
	protected $_name = 'raid_kills';
	protected $_dependentTables = array('RaidDrops');
	protected $_referenceMap = array(
		'Raids'		=> 	array(
						'columns' 		=> array('raid_id'),
						'refTableClass' => 'Raids',
						'refColumns' 	=> array('id')
						),
		'Bosses'	=> 	array(
						'columns' 		=> array('boss_id'),
						'refTableClass' => 'Bosses',
						'refColumns' 	=> array('id')
						),
		'DkpAdjustments'=> 	array(
						'columns' 		=> array('dkp_adjustment_id'),
						'refTableClass' => 'DkpAdjustments',
						'refColumns' 	=> array('id')
						)
	);
	
    /**
	 * Short hand for getting a raidkill by its id.
	 * 
	 * This function does mysql safe escaping on the raidkill id.
	 *
	 * @param 	int 			raid id
	 * @return 	RaidKillRow|null
	 */
	public static function getById($killId)
	{	
		// Raid id must be numeric
		if (!is_numeric($killId)) {
			return null;
		}
		
		// Create static self
		$table = new self();
		
		// Create a select for getting the raid
		$select = $table->select()->where("id = ?", $killId);
		$kill = $table->fetchRow($select);
		
		// Return the raid or null
		if ($kill) {
			return $kill;
		} else {
			return null;
		}
	}
}
?>